Vue.filter('timeStampToTimeText', function (value) {
  var now = new Date().getTime(), temp = new Date(Number(value)).getTime(),
    diff = Math.floor(Math.ceil((now - temp) / 1000) / 60), txt = '';
  if (diff >= 525600) {
    var time = Math.floor(diff / 525600);
    txt = ((time <= 5) ? time : 5) + ' years ago';
  } else if (diff >= 43800 && diff / 43800 <= 12) {
    txt = Math.floor(diff / 43800) + ' months ago';
  } else if (diff >= 10950 && diff / 10950 < 4.5) {
    txt = Math.floor(diff / 10950) + ' weeks ago';
  } else if (diff >= 1460 && diff / 1460 < 7) {
    txt = Math.floor(diff / 1440) + ' days ago';
  } else if (diff >= 60 && diff < 1460) {
    txt = Math.floor(diff / 60) + ' hours ago';
  } else if (diff >= 5 && diff < 60) {
    txt = diff + ' minites ago';
  } else {
    txt = 'just now';
  }
  return txt;
});
Vue.filter('toFixed', function (value, f) {
  value = Number(value);
  return value.toFixed(f) || value;
});
Vue.filter('dateFormat', function (val) {
  var res = new Date(val);
  return [res.getFullYear(), res.getMonth()+1 < 10 ? '0'+(res.getMonth()+1) : (res.getMonth()+1), res.getDate() < 10 ? '0'+res.getDate() : res.getDate()].join('-');
});
